/* test5_1.c ：创建线程 */
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
int data = 4;
void *thereadcode() /*线程的执行代码*/
{
    printf("theread: data=%d\n", ++data);
    pthread_exit(0);    /*线程正常终止*/
    return NULL;
}

int main()
{
    pthread_t tid;  /*声明tid为线程标识号类型*/
    printf("data=%d\n", ++data);
    /*创建线程thereadcode*/
    if (pthread_create(&tid, NULL, thereadcode, NULL) != 0)
    {
        /*创建失败*/
        printf("create of theread is fail\n");
        exit(-1); /*非正常终止*/
    }
    /*等待线程的终止*/
    pthread_join(tid, NULL);
    printf("data=%d\n", ++data);
    return 0;
}

